package com.shijunhao.graduation.utils;

/**
 * @author: shijunhao
 * @date: 2022/3/2 22:32
 * @description:
 */
public class ExceptionUtils {

    public static String printBusinessStackTrace(Throwable e,String packagePrefix){
        StringBuilder sb = new StringBuilder();
        sb.append("\n").append(e);
        for(StackTraceElement stackTraceElement : e.getStackTrace()){
            if(!stackTraceElement.getClassName().startsWith(packagePrefix))
                continue;
            sb.append("\n\tat ").append(stackTraceElement);
        }
        return sb.toString();
    }
}
